#include <algorithm>
#include <cstdint>
#include <iostream>

using ll = int64_t;
using std::cin, std::cout;

const ll maxn = 1e5+5;
ll t, n, a[maxn], ans, inf=(1l<<(sizeof(inf)*8-4));

int main(){
    std::iostream::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

    cin>>t;
    while(t--){
        ans = -inf;
        cin>>n;
        for(ll i{1};i<=n;i++)cin>>a[i];
        for(ll i{1};i<n-1;i++)
            for(ll j{i+1};j<n;j++)
                for(ll k{j+1};k<=n;k++){
                    if(a[i]<a[j] && a[j]<a[k]){
                        ans=std::max(ans, a[i]*a[j]*a[k]);
                    }
                }
        cout<<(ans==-inf?-1:ans)<<'\n';
    }
}